Use case: UART communication in polling mode ¶
Sequence diagram ¶
Code snippet ¶
|
HAL1 |
HAL2 |
|---|---|
#define DATA_TO_SEND_SIZE 256
#define DATA_TO_RECEIVE_SIZE DATA_TO_SEND_SIZE
uint8_t aTxBuffer[] = " **** UART Communication **** ";
uint8_t aRxBuffer[DATA_TO_RECEIVE_SIZE];
UART_HandleTypeDef huart;
HAL_UART_Init(&huart)
HAL_UART_Receive(&huart, aRxBuffer,
DATA_TO_RECEIVE_SIZE, 100)
HAL_UART_Transmit(&huart, aTxBuffer,
DATA_TO_SEND_SIZE, 100)
|
#define DATA_TO_SEND_SIZE 256
#define DATA_TO_RECEIVE_SIZE DATA_TO_SEND_SIZE
uint8_t aTxBuffer[] = " **** UART Communication **** ";
uint8_t aRxBuffer[DATA_TO_RECEIVE_SIZE];
hal_uart_handle_t huart;
hal_uart_config_t uart_config;
HAL_UART_Init(&huart, HAL_UART4)
/* add config for uart instance */
HAL_UART_SetConfig(&huart, &uart_config)
HAL_UART_Receive(&huart, aRxBuffer,
DATA_TO_RECEIVE_SIZE, 100)
HAL_UART_Transmit(&huart,aTxBuffer,
DATA_TO_SEND_SIZE, 100)
|
Key changes ¶
In HAL2, the UART instance is provided to
HAL_UART_Init()and configuration is separated usingHAL_UART_SetConfig().

